<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<html>
<head>
    <title>日志</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <meta name="apple-mobile-web-app-capable" content="yes"/>

    <link type="text/css" rel="stylesheet" href="/lib/budget/styles.css"/>
    <link type="text/css" rel="stylesheet" href="/lib/pagination/style/pagination.css">
    <link rel="stylesheet" type="text/css" href="/css/commonTheme/${sessionScope.InterfaceModel}/commonTheme.css"/>

    <script type="text/javascript" charset="utf-8" src="/lib/jQuery-File-Upload-master/jquery-1.8.3.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="/lib/layer/layer.js?20201106"></script>
    <script type="text/javascript" charset="utf-8" src="/lib/pagination/js/jquery.pagination.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="/js/base/tablePage.js"></script>
    <script type="text/javascript" src="/js/base/base.js"></script>


    <style>
        *{
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        a{
            text-decoration: none;
        }
        table{
            width:100%;
            border-collapse: collapse;
            margin-left: 7px;
            margin: 0 auto;
            table-layout: fixed;

        }
        .fr{
            float: right;
        }
        th,td{
            width:30%;
            border: 1px solid #666666;
            height: 35px;
            font-size: 13px;
            color: #333333;
            text-align: center;
            /*溢出隐藏并显示...*/
            word-break: keep-all;
            white-space: nowrap;
            text-overflow: ellipsis;
            -webkit-box-orient: vertical;
            overflow: hidden;
            text-align: center;
        }
        th{
            background-color: #00ccff;
        }
        .th1{
            width: 10%;
        }
        /*.th2{*/
            /*width: 10%;*/
        /*}*/
        /*.th3{*/
            /*width: 155px;*/
        /*}*/
        /*.th4{*/
            /*width: 112px;*/
        /*}*/
        /*.th5{*/
            /*width: 15%;*/
        /*}*/
        .th6{
            width: 40%;
        }
        /*.th7{*/
            /*width: 85px;*/
        /*}*/
        tr:hover{
            background: #ccc;
            cursor:pointer;
        }
        .ri{
            margin: 0 auto;
            font-size: 20px;
            height: 40px;
            border-bottom: 1px solid #000;
            margin-bottom: 16px;
            width: 995px;
        }
        .del{
            text-decoration: none;
        }
        .del:hover{
            color: red;
        }
        .M-box3{
            margin-top: 30px;
            position: fixed;
            bottom:10px;
            right: 60px;
            text-align: center;
        }


        .jump-ipt{
            width: 38px;
            height: 38px;
            line-height: 38px;
        }
        .p2{
            float: right;
            height: 40px;
            margin-top: 16px;
            margin-right: 278px;
        }

        .quanx{
            cursor:pointer;
            position: relative;
            left: 200px;
        }
        .quanx:hover{
            background-color:#0e6bb7d9;
            color: #fff;
            cursor:pointer;


        }
        .p2{
            float: right;
            height: 40px;
            margin-top: 16px;
            margin-right: 278px;
        }
        .p2 span{
            font-size: 14px;
            background-color: #2b7fe0;
            padding: 4px 18px;
            border-radius: 3px;
            color: #fff;
            cursor: pointer;
        }
        .p1{

            float: left;
            margin-bottom: 0;
            height: 40px;
            padding-left: 10px;
            font-size: 20px;
            line-height: 62px;
            position: relative;
            left: 80px;

        }
        .clearfix:after {
            display: table;
            content: " ";
            clear: both;
        }
        .clearfix{
            border-bottom:1px solid #000;
            margin-bottom: 16px;
        }
        .content{
            margin-right: 1%;
            margin-top: 1%;
        }

        .foot{
            font-size: 14pt;
            /* margin-top: 58px; */
            width: 100%;
            padding: 5%;
        }
        .foot p{
            /*margin: 20px 0; */
            border-bottom: 1px solid #000;
            height: 40px;
            /* padding-left: 8px; */
        }


        #userAdd,#privAdd,#privClear,#userClear{
            font-size: 14px;
            background-color: #2b7fe0;
            padding: 4px 18px;
            border-radius: 3px;
            color: #fff;
            cursor:pointer;
        }
        ul,li{
            list-style: none;
        }
        li{
            margin: 25px 0;
        }
        input[type="text"]{
            position: relative;
            margin: 0;
            padding-left: 10px;
            box-sizing: border-box;
            border: 1px solid rgb(221, 221, 221);
            border-image: initial;
            border-radius: 4px;
        }




        /*弹框样式*/

        .td_title1{
            width: 40%;
            height:32px;
        }
        .biginput{
            width: 40%;
            height: 32px;
            font-size: 13px;
        }
        .ml8{
            margin-left:8px;
        }

        input[type="file"]{

            margin-left: 8px;
        }
    </style>

</head>
<body>
<div class="content">
    <div class="clearfix">
        <p class="p1">修改日志</p>
        <div class="p2">
            <span class="quanx">权限设置</span>
        </div>

    </div>

    <div id="u268">
        <table border="1">
            <thead>
            <tr>
                <th class="th1">序号</th>
                <th class="th2">预算项目名称</th>
                <th class="th2">填报日期</th>
                <th class="th7">操作人用户</th>
                <th class="th6">时间</th>
                <th class="th3">IP</th>
                <th class="th4">类型</th>
                <th class="th5">备注</th>
            </tr>
            </thead>


            <tbody>

            </tbody>
        </table>

        <div id="dbgz_page" class="M-box3 fr" style="margin-top: 29px;">

        </div>
    </div>

</div>
</body>
<script>


    $('.quanx').on('click',function () {
        layer.open({
            type: 1,
            title: ['预算管理日志权限设置', 'background-color:#2b7fe0;color:#fff;'],
//            area: ['500px', '460px'],
            area: ['60%', '70%'],
            shadeClose: false, //点击遮罩关闭
            btn: ['保存', '取消'],
            content: '<div class="foot">' +
            '<p>预算管理日志权限设置</p>' +
            '<ul>' +

            '<li>' +
            '<span>人员：&emsp;&emsp;&emsp;&emsp;</span>' +
            '<span style="position: relative;">' +
            '<input disabled class="td_title1 release1" id="query_toId" type="text" username="">' +
            '<a href="javascript:;" class=" ml8 userPrivAdd userAdd" id="userAdd" name="orgAdd">添加</a>' +
            '<a href="javascript:;" class=" ml8 userPrivClear userClear" id="userClear" name="orgClear">清除</a>' +
            '</span>' +
            '</li>' +
            '<li>' +
            '<span>角色：&emsp;&emsp;&emsp;&emsp;</span>' +
            '<span style="position: relative;">' +
            '<input disabled type="text" name="userPriv" id="userPrivInput"  class="td_title1" value="" privid="" userpriv="">' +
            '<a href="javascript:;" class="ml8 userPrivAdd privAdd" id="privAdd" name="orgAdd" >添加</a>' +
            '<a href="javascript:;" class="ml8 userPrivClear privClear" id="privClear" name="orgClear">清除</a>' +
            '</span>' +
            '</li>' +

            '</ul>' +
            '</div>',
//            保存按钮事件
            yes:function (index) {
                var data={
                    userIds:$("#query_toId").attr("user_id"),
                    userPrivIds:$("#userPrivInput").attr("privid"),
//                    flowId:$("#department").val(),
                    flowId:$('input:checkbox[name="rz"]:checked').val(),
                    documentType:0,
                    dispatchType:'documentDecision',
                    fflowId:$('input:checkbox[name="rz"]:checked').val(),
                    frunId:'',
                    fprcsId:1,
                    fflowStep:1,
                    useFlag:true
                };
                newDocument(data,function(json){
                    if(json.flag){
                        location.reload();
//                          window.open('/documentCenter/handleMain/window?flowId='+json.object.flowId+'&flowStep=1&tableName=document&tabId='+json.object.id+'&runId='+json.object.runId+'&prcsId=1&isNomalType=false')
//                          window.open('budget/upBudgetLogSet')

                        layer.msg("保存成功",{
                            icon: 1,
                            time: 1500 //2秒关闭（如果不配置，默认是3秒）
                        },function(){
                            window.location.reload();
                        });

                    }else {
                        alert("保存失败");
                    }
                    layer.close(index);
                });

            },

            success:function () {


                // 获取人员信息控件
                $("#userAdd").on("click", function (){
                    user_id = "query_toId";
                    $.popWindow("../common/selectUser");
                });
                // 清空人员信息
                $('#userClear').click(function () {

                    $('#query_toId').attr("username", "");
//                    $('#query_toId').attr("userpriv", "");
                     $('#query_toId').val("");
                    $.ajax({
                        url:'/budget/delBudgetLog',
                        type:'post',

                        dataType:'json',
                        success:function(result){
                            if(result.msg=='ok'){
                                layer.msg("取消成功",{
                                    icon: 1,
                                    time: 1500 //2秒关闭（如果不配置，默认是3秒）
                                },function(){
                                    window.location.reload();
                                });

                            }

                        },
                        error:function(){

                        }
                    });
                });
                //获取角色信息控件
                $("#privAdd").on("click", function (){
                    priv_id = "userPrivInput";
                    $.popWindow("../common/selectPriv");
                });
                // 清空角色信息
                $('#privClear').click(function () {
                    $('#userPrivInput').attr("privid", "");
                    $('#userPrivInput').attr("userpriv", "");
                    $('#userPrivInput').val("");
                });
                //取消权限
                $('.cancelQx').click(function () {
                    $.ajax({
                        url:'/budget/delBudgetLog',
                        type:'post',

                        dataType:'json',
                        success:function(result){
                            if(result.msg=='ok'){
                                layer.msg("取消成功",{
                                    icon: 1,
                                    time: 1500 //2秒关闭（如果不配置，默认是3秒）
                                },function(){
                                    window.location.reload();
                                });

                            }

                        },
                        error:function(){

                        }
                    });
                });






            }
        });


        $.ajax({
            type:'get',
            url:'/budget/selBudgetLogSet',
            dataType:'json',
            success:function(res){
                var str=''
                if(res){
                    var i =0;
                    console.log(res.obj);


                    $.each(res.obj,function(index,item){

                        var str ="";
                        $.each(res.obj, function (index, obj) {
                            console.log(obj.userName)
                            str +=obj.userName+',';
                            $("#query_toId").val(str)
                        });

                        if(item.budgetLogSet==0){
                            $('.quanx').css('display','inline-block')
                        }
                    })
                    $('table').append(str)
                }

            }
        })



    });

    function newDocument(data,resultFn) {
        $.ajax({
//              url:'/document/saveDoc',
            url:'/budget/upBudgetLogSet',
            type:'post',
            data:data,
            dataType:'json',
            success:function(result){
                resultFn(result)
            },
            error:function(){

            }
        });
    } //end for newDocument
            function undefinedData(data) {
                if(data == "undefined"){
                    return '';
                }else{
                    return data;
                }
            }

    var ajaxPage={
        data:{
            page:1,//当前处于第几页
            pageSize:5,//一页显示几条
            useFlag:true
        },
        page:function () {
            var me=this;
            $.post('/budget/selAllBudgetLog',me.data,function (json) {
                var str='';
                var arr=json.obj;
                for(var i=0;i<arr.length;i++){
                    str+= '<tr budgetId="'+arr[i].logId+'">'+
                        '<td>'+(i+1)+'</td>'+
                        '<td title="'+undefinedData(arr[i].budgetItemName)+'">'+undefinedData(arr[i].budgetItemName)+'</td>'+
                        '<td title="'+undefinedData(arr[i].budgetInputTime)+'">'+undefinedData(arr[i].budgetInputTime)+'</td>'+
                        '<td title="'+undefinedData(arr[i].userId)+'">'+undefinedData(arr[i].userId)+'</td>'+
                        '<td title="'+undefinedData(arr[i].time)+'">'+undefinedData(arr[i].time)+'</td>'+
                        '<td title="'+undefinedData(arr[i].ip)+'">'+undefinedData(arr[i].ip)+'</td>'+
                        '<td title="'+undefinedData(arr[i].type)+'">'+undefinedData(arr[i].type)+'</td>'+
                        '<td title="'+undefinedData(arr[i].remark)+'">'+undefinedData(arr[i].remark)+'</td>'+
                        '</tr>'
                }
//                $('table').append(str)
                $('#u268 table tbody').html(str)
                me.pageTwo(json.totleNum,me.data.pageSize,me.data.page)
            },'json')
        },
        pageTwo:function (totalData, pageSize,indexs) {
            var mes=this;
            $('#dbgz_page').pagination({
                totalData: totalData,
                showData: pageSize,
                jump: true,
                coping: true,
                homePage:'',
                endPage: '',
                current:indexs||1,
                callback: function (index) {
                    mes.data.page=index.getCurrent();
                    mes.page();
                }
            });
        }
    }
    ajaxPage.page();

    $('table').on('click','.del',function(){
        var budgetId=$(this).parent().parent().attr('budgetId')
        var This = this;
        layer.open({
            type: 1,
            title: ['提示','background-color:#2e8ded;color:#fff'],
            content:'<div style="text-align: center;margin-top: 18px;">确认删除吗？</div>',
            area: ['200px', '160px'],
            btn: ['确认','取消'],
            yes:function(index){
                $.ajax({
                    url:'/budget/delBudgetLogById',
                    type:'post',
                    data:{
                        'logId':budgetId
                    },
                    dataType:'json',
                    success:function(res){
                        layer.close(index)
                        if(res){
                            layer.msg("删除成功",{
                                icon: 1,
                                time: 1500 //2秒关闭（如果不配置，默认是3秒）
                            },function(){
                                window.location.reload();
                            })
                        }else {
                            layer.msg("删除失败",{
                                icon: 2,
                                time: 1500 //2秒关闭（如果不配置，默认是3秒）
                            })
                        }
                    }
                })
            },
            btn2: function (index) {
                layer.close(index)
            },
            btnAlign:'c',

        })
    });
</script>
</html>
